package com.cheer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cheer.dao.OaGroupActivityImageDao;
import com.cheer.entity.OaGroupActivityImageEntity;
import com.cheer.service.OaGroupActivityImageService;
import com.cheer.vo.OaBannerSimpleVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service("oaGroupActivityImageService")
public class OaGroupActivityImageServiceImpl extends ServiceImpl<OaGroupActivityImageDao, OaGroupActivityImageEntity> implements OaGroupActivityImageService {

    @Value("${image.url}")
    private String imageUrl;

    @Override
    public List<OaBannerSimpleVO> listImages() {
        List<OaGroupActivityImageEntity> list = baseMapper.selectList(new QueryWrapper<OaGroupActivityImageEntity>()
                .eq("show_status", true));
        return list.stream()
                .map(oaGroupActivityImageEntity -> new OaBannerSimpleVO()
                        .setHref(oaGroupActivityImageEntity.getHref())
                        .setImgUrl(imageUrl + oaGroupActivityImageEntity.getImageUrl()))
                .collect(Collectors.toList());
    }
}